<?PHP
$id = $_POST['id_image'];

include_once "ini.php";
dbconnect();

$sql = "SELECT * FROM images WHERE id_image = '".$id."'";
$result = mysql_query($sql);
if (!$result)
{
    echo "SQL error : ", $sql;
    exit ;
}
else
{
	while($tab = mysql_fetch_assoc($result)){
	$droit = ($tab['droit'] == "public")?"private":"public";
	$sql2 = "UPDATE `images` SET `droit` = '".$droit."' WHERE `images`.`id_image` = '".$id."';";
            $requete = mysql_query($sql2);
            if (!$requete)
            {
                echo "SQL error : ", $sql2;
                exit ;
            }
            else
            {
                echo "save right done \r\n";

            }
	}
}
dbclose();
?>